from pydantic_settings import BaseSettings
from typing import Optional

class Settings(BaseSettings):
    PROJECT_NAME: str = "URL Shortener"
    VERSION: str = "1.0.0"
    API_V1_STR: str = "/api/v1"
    
    # MySQL配置
    MYSQL_USER: str = "root"
    MYSQL_PASSWORD: str = "admin"
    MYSQL_HOST: str = "127.0.0.1"
    MYSQL_DB: str = "url_shortener"
    DATABASE_URL: Optional[str] = None
    
    # Redis配置
    REDIS_HOST: str = "localhost"
    REDIS_PORT: int = 6379
    REDIS_DB: int = 0
    REDIS_URL: str = "redis://localhost:6379/0"
    
    # JWT设置
    SECRET_KEY: str = "your-secret-key"  # 确保使用安全的密钥
    ALGORITHM: str = "HS256"  # JWT 使用的算法
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30  # 访问令牌过期时间
    
    class Config:
        env_file = ".env"

settings = Settings() 